home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Newsletters / GEnieUnixNews / unxnl-08.92 < prev    next >
Text File  |  1992-12-27  |  40KB  |  995 lines

  1.  
  2.           _  _  _   _  _   _
  3.          // // //| // // \//     N E W S
  4.         //_// // |// //  /\\     Vol 3, Issue 6 - August 1992
  5.       R o u n d T a b l e (tm)
  6.  
  7.    Items of interest to participants of the GEnie Unix RoundTable
  8.  
  9.        The RoundTable SysOps are:
  10.        Andy Finkenstadt....ANDY       Rick Mobley.........LRARK
  11.        Gary Smith..........GARS       Brian Riley.........DELPHI
  12.        Mike Nolan..........M.NOLAN    All Unix SysOps.....UNIXSYSOPS$
  13.    We strongly encourage you to contact any or all of us if you have -ANY-
  14.  comments or suggestions. This is -YOUR- RoundTable. We are here to make
  15.  your participation as pleasant and beneficial as possible.
  16.  
  17.  ED: editor notes - Unix RT as a resource (GARS) Gary Smith
  18.  ==
  19.  
  20.    The value of the GEnie Unix RoundTable as a resource to you continues to
  21.  grow. Since the last newsletter Mark Williams has added Coherent support.
  22.  This is an indication of their dedication to their customer base. They
  23.  deserve a round of appreciative applause for this attitude.
  24.  
  25.    The internet mail connection to GEnie is now a reality and the Unix RT
  26.  will be the resource center for information regarding access to and usage
  27.  of this valuable tool. The list of FAQ (Frequently Asked Questions) and
  28.  information files in our library explaining aspects of internet is quite
  29.  large and growing.  The Unix RoundTable has also been providing a internet
  30.  help desk in our Real Time Conference area and also in CHAT. See Andy's
  31.  Lead SysOp notes below for more on the internet connection and the help
  32.  desk.
  33.  
  34.    Thanks to you, our users, the GEnie Unix RoundTable continues to evolve
  35.  into the friendly response center we have worked to make it since we came
  36.  on line at the end of 1989. Please continue to push us in the directions
  37.  you want us to grow with your comments in the Bulletin Board and via the
  38.  Feedback Item on our main menu.
  39.  
  40.  Lead Sysop Notes (ANDY)  Andrew Finkenstadt
  41.  ================         Chief Sysop
  42.  
  43.  
  44.  Conference Announcement
  45.  
  46.  MEET THE GEnie-INTERNET GATEWAY DEVELOPER
  47.  
  48.  Tuesday August 25, 1992 at 10:00pm Eastern Time
  49.  
  50.  Walt Meffert, developer of the Internet Gateway on the GEnie Service, will
  51.  be appearing in the Unix Conference Hall on GEnie page 160, keyword UNIX.
  52.  Walt will be speaking on issues and topics of interest about the Internet
  53.  gateway.
  54.  
  55.  As part of the GEnie Hot Summer Nights promotion, the conference itself
  56.  will be covered under the GEnie*Basic Services pricing plan.  Seating is
  57.  limited, so plan on showing up a few minutes before the hour (but after
  58.  9:50pm EDT) to get a front-row chair.
  59.  
  60.  ----------
  61.  
  62.  INTERNET Announcement
  63.  
  64.  GEnie is now testing its Internet gateway.  YOU can take part in
  65.  the public "Beta Test" by stopping at page 207, keyword INTERNET
  66.  and signing up for the gateway.  (Some charges apply, so be sure
  67.  to read the 'About' and 'Rates' menu items before subscribing.)
  68.  
  69.  The Unix RT staff has been excitedly waiting for this public
  70.  testing period.  In preparation the Unix RT staff has been
  71.  working to proudly host a large repository of Internet
  72.  information on GEnie in both the bulletin board (category 12) and
  73.  in the software libraries.  A list of these files can be found by
  74.  searching for the keyword "INTERNET" in the software library.
  75.  
  76.  And in addition from now until Thursday, August 13 from 9pm until
  77.  midnight eastern daylight time the Unix RT is sponsoring an
  78.  INTERNET HELP DESK for those interested in information about
  79.  GEnie's Internet Gateway.  Just stop by and ask questions and
  80.  receive answers LIVE and instantly.
  81.  
  82.  ----------
  83.  
  84.  Upload Contest Winners for July (ANDY)
  85.  ================================
  86.  
  87.  To:     S.SUMMERS1                      Sean D. Summers
  88.  
  89.  Sub: Congratulations!
  90.  
  91.  Congratulations to Sean Summmers for winning two free days in the
  92.  Unix RT.
  93.  He uploaded the excellent communication program for Unix called
  94.  "pcomm," a ProComm work-alike that supports Xmodem, Ymodem, and
  95.  Zmodem, and a scripting capability.
  96.  
  97.  You too can win one or more free days in the Unix RT.  Download
  98.  file #2346, CONTEST.RULES, for complete instructions and
  99.  qualification criteria.
  100.  
  101.  -Andy
  102.  
  103.  ----------
  104.  
  105.  usr/local: Items (scripts and news) snarfed from various sources
  106.  =========
  107.  
  108.  Comparing Features Available on Various Shells (GARS) Gary Smith
  109.  ----------------------------------------------
  110.  
  111.  |                     SHELL TYPE -------->
  112.  | FEATURE              Bourne    CShell    Korn      TShell
  113.  V                      (sh)      (Csh)     (ksh)     (tcsh)
  114.  
  115.    Aliasing             No        Yes       Yes       Yes
  116.    History Substitute   No        Yes       Yes       Yes
  117.    Tilde Substitution   No        Yes       Yes       Yes
  118.    Array Support        No        Yes       Yes       Yes
  119.    Relative Speed       >Csh      ---       <sh       =Csh
  120.    Job Control          No        Yes       Yes       Yes
  121.    Command Line Edit    No        Limited   vi/Emacs  Emacs
  122.    Filename Expansion   Limited   Limited   Limited   Extensive
  123.    Directory Stack      No        Yes       Yes       Yes
  124.    Built-in Commands    Yes       >sh       >Csh      >Csh
  125.    Security             Poor      Poor      >Csh      >Csh
  126.    Keyboard Binding     No        Limited   Limited   Yes
  127.    Internationalizaton  No        Yes       No        No
  128.    Diagnostics          Very Poor Poor      Good      Poor
  129.    String Manipulation  No        Yes       Yes       Yes
  130.    MultiBase Arithmetic No        No        Yes       No
  131.    I/O Files Open       One       One       Multiple  One
  132.  
  133.  
  134.  and this from Usenet newsgroup comp.unix.shell on shell comparisons:
  135.  
  136.  Article 4856 of comp.unix.shell:
  137.  From: deudon@goofi.greco-prog.fr (DEUDON Guillaume.)
  138.  Newsgroups: comp.unix.shell
  139.  Subject: Re: List of Shells and Descriptions?
  140.  Message-ID: <6885@geocub.UUCP>
  141.  Date: 2 Jun 92 11:42:45 GMT
  142.  References: <1992May29.132111.3144@kocrsv01.delcoelect.com>
  143.  Sender: lnews@geocub.UUCP
  144.  Organization: Computer Engineering,ENSERB,University Of Bordeaux,FRANCE.
  145.  
  146.  In article <1992May29.132111.3144@kocrsv01.delcoelect.com>
  147.  swlodin@kocrsv01.delcoelect.com (Steve Lodin) writes:
  148.  >
  149.  >Is there a list of shells (sh, csh, ksh, tcsh, bash, zsh, rc, ...)
  150.  >along with a history and description of "neat" features?  A pointer to
  151.  >a FAQ or archive site would be nice.
  152.  >Thanks alot!!!
  153.  >Steve
  154.  
  155.  From an older posting ...
  156.  
  157.  ---------------------------------------------------------------------------
  158.  
  159.  Newsgroups: comp.unix.shell
  160.  Subject: An extensive comparison of 'sh' and 'csh' language features
  161.  Message-ID: <KLM.91Nov21100557@glyph.cme.nist.gov>
  162.  Date: 21 Nov 91 15:05:57 GMT
  163.  Sender: news@cme.nist.gov
  164.  Distribution: comp
  165.  Organization: National Institute of Standards and Technology
  166.  Keywords: sh csh scripting interaction language comparison
  167.  
  168.  Below is a presentation which i put together about particularly
  169.  consequential functional differences between the 'sh' and the 'csh'
  170.  shell command languages.  I've seen many assertions, in Unix
  171.  introductory books, in news postings, etc., about how sh is better for
  172.  scripting, or csh is better for interactions (and sometimes vice-
  173.  versa), but i don't think i've ever seen a direct comparison.  I'm
  174.  posting a start on such a beast in case anyone else might find it
  175.  useful, and also because i'm interested in filling in gaps - hearing
  176.  from others about important differences in functionality between the
  177.  two shell languages that i've missed (or gotten wrong).
  178.  
  179.  The details are taken from the slides i made for an informal
  180.  presentation which i gave (at our CLUB - Computer Users Lunch Bunch)
  181.  recently at work.  The presentation came out of notes that i
  182.  accumulated while idly thinking back (a late at night kind of thing,
  183.  and in fact, when i actually wound up generating the notes) to my own
  184.  experiences switching from csh- to sh-based shells both for scripting
  185.  and for my interactive login shell.
  186.  
  187.  There is a preamble before the comparison which presents some of the
  188.  rationale i went through for even considering investing the energy to
  189.  scope out a whole new shell.  Before looking at 'sh' i was very
  190.  steeped in 'csh' - i do system and user support, and so answer lots of
  191.  shell interaction and script questions, and have implemented a few
  192.  very substantial scripts in csh.  (Some of you may be familiar with
  193.  '8mmbackup', a script that i wrote which a number of people around the
  194.  net have been using.  I've also done a few other utilities in 'csh',
  195.  and now some big ones in 'sh'.)  The combination of an interactive
  196.  shell with formidable interaction conveniences, like GNU-emacs-like
  197.  command-line interaction conveniences and so forth, built in shell
  198.  functions, and greater prospects for POSIX compatibility, finally
  199.  prompted me to take a serious look, at least, at making the switch to
  200.  a 'sh'-based shell.
  201.  
  202.  I can't be more emphatic that scripting in 'sh' is more manageable
  203.  than in 'csh', almost without regard to what you're doing, and the
  204.  benefits only increase as your job scales up.  The point of my
  205.  presentation, however, is that 'sh' language strengths are not only of
  206.  benefit for scripting - given the addition of user conveniences like
  207.  history, tilde notation, command line editing, and so forth, i find
  208.  that 'sh' makes a much better interactive command language substrate.
  209.  Hopefully this presentation begins to indicate some of the reasons for
  210.  this.
  211.  
  212.  Ken Manheimer                      Nat'l Inst of Standards and Technology
  213.  klm@cme.nist.gov (301)975-3539     (Formerly Nat'l Bureau of Standards)
  214.        Factory Automation Systems Division Unix Systems Support Manager
  215.  
  216.                                    I like time.  It's one of my favorites.
  217.  
  218.                         A Comparison of Primary
  219.  
  220.                               UNIX SHELLS
  221.  
  222.                     Ken Manheimer (klm@cme.nist.gov)
  223.  
  224.              National Institute of Standards and Technology
  225.  
  226.                          WHAT ARE UNIX SHELLS?
  227.  
  228.   - Containers for delivery of explosive charges? Houses for mollusks?
  229.  
  230.  The ones i'm talking about are a sort of container, but in a more
  231.  abstract way...
  232.  
  233.   - Unix shells are command interfaces for using computer software.
  234.  
  235.   - In the most rudimentary sense, each command shell, in general,
  236.     provides an interactive base from which to successively `launch'
  237.     applications.
  238.  
  239.   - Any but the most minimal shell (CPM?) provides means for connecting
  240.     things together:
  241.  
  242.      Environment - an operating context with state, which you can use
  243.      to adjust/tailor your command interpreter in a systematic way - eg
  244.      env vars, command history, command substitution, ...
  245.  
  246.      Glue - mechanisms for connecting together separate application
  247.      operations in more than just sequence.
  248.  
  249.   - Differences get complex at this point.
  250.  
  251.                       WHAT ARE THE CHOICES ABOUT?
  252.  
  253.  In UNIX, the glue is particularly important. UNIX' adheres to a policy
  254.  of promoting pervasive interconnectivity between applications.
  255.  
  256.   - This endows the potential both for powerful benefits in command
  257.     composition...
  258.  
  259.   - ... As well as requiring accommodation for the implicit tendency
  260.     towards limiting of the power of individual commands.
  261.  
  262.  Sophistication in command shells allowed their effective use beyond
  263.  immediate user interaction, as script programs for engaging
  264.  applications, in addition to interactive employment.
  265.  
  266.  Divergence of two shells primary shells, csh and sh, stress different
  267.  strengths. The choices would be relatively easy if that's all there
  268.  was. But it isn't.
  269.  
  270.                            IN SIMPLER DAYS...
  271.  
  272.  There was a time, after the beginning but before today, when the
  273.  choices were limited to `sh' (particularly the enhanced versions of
  274.  bourne shell) and `csh', and their relative strengths are fairly
  275.  clear cut (about which, more detail further below).
  276.  
  277.  Sh is a worse interaction language -
  278.  
  279.     lacks job control
  280.     lacks command history (indispensable if only for `!!')
  281.     lacks tilde abbreviation ("~klm/.cshrc")
  282.  
  283.  Csh is a worse programming language -
  284.  
  285.     lacks scoped functions
  286.     lacks fine granularity file IO
  287.     often less robust syntax and semantics
  288.  
  289.  (It may even be reasonable to say that, for the times, and combined
  290.  with the peculiar compositional strengths of UNIX utilities, the
  291.  shells were relatively good at what they were supposed to do.)
  292.  
  293.  
  294.                               A WRINKLE...
  295.  
  296.  Due to `csh' distinct and substantial interaction conveniences, and
  297.  despite `sh' programming-language advantages, it has been fairly easy
  298.  to choose csh (or some enhanced csh) for your command interaction
  299.  mechanism.
  300.  
  301.  But now, suppose that you could have all the interaction benefits of
  302.  csh, as well as prevalent refinements, etc, but built on top of either
  303.  csh or sh.
  304.  
  305.  ** Would the programming benefits of `sh' be of great enough benefit
  306.     for the sake of interactive use to warrant the effort of learning a
  307.     different command language for use as your login shell?
  308.  
  309.  In fact, two of the most prevalent contemporary alternative shells,
  310.  csh-oriented `tcsh' and sh-oriented `bash', are similar enough in pure
  311.  interaction refinements that you would have to consider just this
  312.  question to decide between them. I think it's worth considering.
  313.  
  314.  
  315.                              THE COMPARISON
  316.  
  317.  Shell (bourne, csh) comparison
  318.  
  319.         INTERACTION CONVENIENCES
  320.  
  321.    - history
  322.    - sh: no
  323.    - csh: yes
  324.    - tilde notation
  325.    - sh: no
  326.    - csh: yes
  327.    - job control
  328.    - sh: no
  329.    - csh: yes
  330.    - invocation shorthand and overload
  331.    - See routines, below.
  332.    - sh: sh functions - kinda powerful
  333.    - csh: aliases - way feeble (but cute)
  334.    - excluding merits of sh functions (below),
  335.      csh slaughters sh for interaction conveniences.
  336.  
  337.         COMPOSITION OF ROUTINES
  338.  
  339.    - sh: scoped functions
  340.    - somewhat scalable - can recurse
  341.    - no direct, persistent nested state
  342.    - ie, routine 'packages' (modules)
  343.      only by virtue of sub-shells.
  344.    - csh: alias and labeled goto
  345.    - goto - unstructured - no scoping
  346.    - alias - textual substitution
  347.    - single cmd or *brief* sequence
  348.    - also no scoping
  349.    - unruly - no syntactic integrity
  350.    - bad partitioning between routine
  351.      interior and invocation -
  352.      outrageously awkward quoting
  353.    - can encode syntactic fragments,
  354.      eg 'if' part o'if/then/else/endif
  355.    - has some "benefits", eg 'ifHostIn'
  356.     -----------------------------------
  357.     set hostname=`/bin/hostname`
  358.     alias ifHostIn echo "\!* | grep -s $hostname;" 'if ($status == 0) then'
  359.     alias ifHostNotIn echo "\!* |grep -s $hostname;" 'if ($status==1) then'
  360.     # Obtain accurate date from internet date
  361.     # server if you're durer, or from durer
  362.     # if you're not durer.
  363.       ifHostNotIn durer
  364.        rdate durer > /dev/null
  365.        echo -n " rdate"
  366.      else
  367.     # india.colorado.edu is a reliable authority:
  368.        set rdateMaster=india.colorado.edu
  369.        rdate $rdateMaster
  370.        echo -n " rdate($rdateMaster)"
  371.       endif   ## ifHostNotIn durer ##
  372.     
  373.     # BUT YOU CANNOT:
  374.  
  375.     # ifHostIn durer goon lurch squire mogul
  376.     #   <do some stuff you want to do on them all>
  377.     #   ifHostNotIn durer
  378.     #     <do some stuff you want to do on all but durer>
  379.     #   endif
  380.     # endif
  381.     # Csh gets badly confused, misses an endif and considers
  382.     # *everything* below as being within the condition.
  383.    --------------------------------------------
  384.    - comparison
  385.    - csh routines don't scale up
  386.    - no scoping
  387.    - limited to brief compositions
  388.    - sh routines do, moderately
  389.  
  390.          I/O
  391.  
  392.    - input reads - sh more powerful
  393.    - any input line by line: sh only
  394.    - This is significant.
  395.    - Eg can read and process pipeline
  396.      output line-by-line in sh, not
  397.      so in csh.  (Unless save the output
  398.      in a file and do a separate pass
  399.      through the entire file for each line!)
  400.    - token parsing reads: sh only
  401.    - token syntax manipulation: sh only
  402.    - by adjusting IFS var value
  403.    - see string data type stuff, above
  404.    - redirection - sh more powerful
  405.    - stderr to stdout: both
  406.    - sh: cmd 2>&1
  407.    - csh: cmd |& cat
  408.    - csh: cmd >& /dev/tty
  409.    - stdout to stderr: sh only
  410.    - cmd 1>&2
  411.    - persistent redirection: sh only
  412.    - 4>&1 #register for resurrection
  413.      1>& wherever   #redirect stdout
  414.      cmd       #output to 'wherever'
  415.      ...   #Output still to wherever
  416.      1>&4  #resume registered stdout
  417.  
  418.       DATA TYPE COMPOSITION AND HANDLING
  419.  
  420.    - string-oriented conditionals
  421.    - sh: idioms using IFS for parsing.
  422.        For example, a func that gets the
  423.        final component of a Unix path:
  424.       PathTail () {
  425.         # Return final path (or token) component of $1
  426.         wasIFS="$IFS"; IFS="/$IFS"          #Prepend '/' to IFS repertoire.
  427.         for bucket in $1; do : ; done       # Loop with '/' as white space.
  428.         IFS="$wasIFS"                       # resurrect preexisting IFS.
  429.         echo $bucket; }
  430.      While this is a trivial case, the
  431.      mechanism is general, useful for
  432.      many things...
  433.    - csh: var tail/head/... for parsing
  434.    - Slightly more convenient but more
  435.      limited than corresponding sh idioms
  436.    - Neither provides string dissection
  437.      (ie, no "substring <string> 3 4")
  438.    - (tho u could do it, using, eg, case,
  439.      and bending over backwards)
  440.    - In sum, csh does some stuff more
  441.      conveniently but doesn't do near
  442.      as much, nor near as coherently.
  443.    - arrays
  444.    - csh has array-style ref to tokens
  445.    - feebly implemented but terse
  446.    - sh uses iteration idioms
  447.    - comprehensive but not terse
  448.  
  449.            HASHING
  450.  
  451.    - sh: on demand, settable, clearable
  452.    - csh: unitary pre hashing, redoable
  453.    - Probably not determined which is
  454.      preferable for general case.
  455.  
  456.        FEATURE SUMMARY
  457.  
  458.    - csh has history, tilde, and
  459.      (somewhat dubious) syntax-fragment
  460.      textual substitution, lacking in sh.
  461.      All primarily instrumental in facilitating
  462.      command interaction.
  463.  
  464.    - Sh has much more powerful routine
  465.      and data composition features,
  466.      redirection features, and string
  467.      and token handling features.  These
  468.      are essential programming features.
  469.  
  470.    - (As mentioned,) csh is better for
  471.      interaction, and sh is better for programming.
  472.    - csh does not scale up as programming language
  473.  
  474.    - some of sh programming advantages are *very*
  475.      conducive for interaction.
  476.    - Eg, can read and process pipeline
  477.      output line-by-line in sh, *not* so
  478.      (without heinous finagling) in csh.
  479.    - Functions provide much more robust -
  480.      powerful and well-behaved - command
  481.      substitution mechanism, facilitating
  482.      easy (on-the-fly) and deep environment
  483.      customization advantages.
  484.  
  485.    - Given inclusion of contemporary interaction
  486.      facilities, as in bash and even 'ksh', at
  487.      least some people may find distinct advantage
  488.      in switching over to a sh-based shell.
  489.  
  490.   That's it.
  491.  
  492.   ------------------------------------------------------------------------
  493.   Enjoy !
  494.  
  495.   Guillaume.
  496.   --
  497.   [g.d]
  498.   ------------------------------------------------------------------------
  499.              "These are a few of my favourite things ..."
  500.  
  501.  Tutorials
  502.  =========
  503.  
  504.  DOS Does Unix  (M.NOLAN)   Mike Nolan    Part 1 in a series
  505.  -------------
  506.  
  507.  Those of us who use more than one type of computer on a daily basis suffer
  508.  from a disease called interface-itis.  Remembering which wild cards work on
  509.  what system, which word processor or editor uses what keys to enter Insert
  510.  mode, even remembering what parameters go with which command.  And some
  511.  of the alternatives get a bit sticky, or is that GUI?  <loud groan>
  512.  
  513.  Since this is, after all, the GEnie Unix RoundTable, this is the first in
  514.  a series of columns which will explore just how close to a unix-like
  515.  environment one can create on a DOS system.
  516.  
  517.  Peruse the Unix RT Library and you will find 200 or more files which deal
  518.  with DOS versions of familiar (or not-so-unfamiliar) commands to unix users.
  519.  Add to this several commercial products and there is material which will
  520.  take several months to cover.
  521.  
  522.  My plan is to first look at the 'complete' packages, and then to
  523.  move on to individual commands.  (This will mean some double coverage
  524.  for certain commands, because there are versions of them in packages
  525.  and as individual files.)
  526.  
  527.  This initial installment will deal with the MKS Toolkit, a commercial
  528.  package.  Being a commercial product, my expectations were high, and
  529.  justifiably so.  In fact the MKS Toolkit programs will serve as the
  530.  benchmark by which I will measure other packages and files.
  531.  
  532.  The MKS Toolkit (Version 3.2c)
  533.  === === ======= ==============
  534.  
  535.  History records that George Washington Carver was the first to make a
  536.  silk purse out of a sow's ear.  Let it be known that Mortice Kern Systems
  537.  (MKS) has nearly achieved the same feat, by providing an environment
  538.  under MS-DOS that is very close to Unix.  Of course, Carver was a chemist,
  539.  MKS's programmers are closer to magicians.
  540.  
  541.  The MKS Toolkit is actually one part of a suite of packages called the
  542.  MKS Programming Platform.  The other parts are MKS Lex and Yacc, MKS Make,
  543.  and MKS RCS.  (These will be covered separately in future installments.)
  544.  
  545.  MKS has both DOS and OS/2 versions of the Toolkit, but only the DOS version
  546.  is being reviewed here.
  547.  
  548.  There are 126 programs in the MKS Toolkit:
  549.  
  550.  asa awk awkl banner basename bc bdiff c cal calendar cat cd
  551.  chmod cksum clear cmp comm compress cp cpio crypt csplit ctags
  552.  cut date dc dd deroff dev df diff diff3 diffh dirname du echo
  553.  ed egrep env expand expr fg fgrep file find fmt fold getconf
  554.  getopt grep gres head help id jobs join kill lc line login
  555.  logname look ls m4 mailx man mkdir mksinfo more mv nl nm od pack
  556.  passwd paste patch pathchk pax pcat pg pr printf prof ps pwd
  557.  rev rm rmdir sed sh size sleep sort spell split strings strip sum
  558.  switch sync tail tar tee test time touch tr tsort tty uname
  559.  uncompre unexpand uniq unpack unstrip uudecode uuencode vi
  560.  wc which who xargs zcat
  561.  
  562.  To be fair, some of these are variants, such as awk and awkl (a version
  563.  for large programs), and egrep/fgrep/grep.  (There are also separate
  564.  versions of awk for systems with and without an 80x87 math co-processor.)
  565.  
  566.  On balance, though, the list is amazingly complete, and the programs are
  567.  generally either very faithful replicas of their unix counterparts or
  568.  improvements upon them.  Most comply with the Posix 2 draft guidelines,
  569.  at least to the extent that DOS permits them to.  MKS has added some
  570.  enhancements of their own to several programs.  A GLOB.EXE program takes
  571.  care of unix-like wildcard expansions when the Toolkit is run from a DOS
  572.  COMMAND.COM shell.
  573.  
  574.  To go through the entire list would take too much space, which for most
  575.  commands would say 'this works just like the unix version', so I will
  576.  cover only the commands that caught my interest.  The 'major' programs
  577.  will be covered in more depth in future columns along with their
  578.  counterparts in other packages or files.  I did find a few errors in
  579.  some of the commands, and MKS has acknowledged one of them as not
  580.  following the Posix standard.
  581.  
  582.  The 'tar' program tries to make file names comply with DOS's 8.3
  583.  restriction, by eliminating all but the last period.  (File name
  584.  truncation may occur, and it will take the first 8 characters to the
  585.  left of the final period and the first 3 characters following it as the
  586.  file name.)
  587.  
  588.  Of course, user and group ownership and most of the file permission
  589.  attributes cannot be set, since DOS doesn't support them.  (As readers of
  590.  the Unix RT BBS may recall, one of our users recently used the MKS Toolkit
  591.  tar program to unpack an 18MB tar file, containing something like 5000
  592.  files in 800 separate directories.)
  593.  
  594.  However, the documentation for tar claims that it will not overwrite an
  595.  existing file, which it silently does.  Further, the '-w' parameter is
  596.  supposed to pause before each operation and wait for a response beginning
  597.  with 'y' to proceed with the operation.  In fact, a 'y' skips the
  598.  operation, and any other response, such as 'n', results in the operation
  599.  being performed.
  600.  
  601.  The 'vi' program is excellent, although I did find a minor bug in it,
  602.  involving the placement of the cursor after a 'P' or 'p' paste operation.
  603.  It is capable of editing very large files, up to 65000 lines each 1K
  604.  long.  While I didn't actually try one that big, I did successfully edit
  605.  a 3MB file.  At one point while editing a file I hit several keys near the
  606.  BACKSPACE key and the program aborted.  There is no recovery mode in DOS,
  607.  so I lost a half hour or so of program editing.
  608.  
  609.  The 'more' program is capable of paging backwards through text, and
  610.  has options that handle ANSI escape sequences properly.  (Unix users
  611.  may recognize the paging backwards feature as the 'less' program.)
  612.  It is not very tolerant of almost-text files, though.
  613.  
  614.  The 'lc' program lists files in columns, rather like ls, except that it
  615.  gives separate lists of directories, files, read-only files, and system
  616.  files.  'lc -d' gives a list of only the directories found.  I liked this
  617.  tool so much I located source for it for my Unix systems.  (And uploaded
  618.  this source to the Unix RT Library.)
  619.  
  620.  Perhaps the best part of the MKS Toolkit is the misnamed 'sh', actually
  621.  the Korn shell.  It can be executed from a DOS prompt, loaded as the
  622.  primary shell in the CONFIG.SYS file, or even with an 'init' program
  623.  to produce a 'login:' prompt, just like on a Unix system.  This third
  624.  combination permits multiple users to each have separate setups,
  625.  including home directories, and entries in the /etc/passwd file can be
  626.  used to load the COMMAND.COM shell or Microsoft Windows from the
  627.  'login:' prompt.
  628.  
  629.  Neither of my Unix systems have the Korn shell on them, but I was able
  630.  to execute several bourne shell scripts, after a few minor changes to
  631.  bring file names into DOS compliance.  Under COMMAND.COM, the MKS tools
  632.  will work with either '/' or '\' in file names, although under the
  633.  Korn shell '/' is required since '\' has a special meaning to the
  634.  shell interpreter.  (This means that when a command line for a DOS
  635.  program must have a full file name on it it may take some extra
  636.  keystrokes to pass the '\' through the interpreter to the program.)
  637.  
  638.  Under the Korn shell, the 'mailx' command works with separate mail files
  639.  for each logon ID, but there is no provision built in for routing mail to
  640.  another system.
  641.  
  642.  Under DOS 5.0 and QEMM 386 6.02, the Korn shell leaves 572,000 bytes
  643.  of memory free.  Using the 'init' program in CONFIG.SYS, this drops
  644.  to 568,000.  Loading COMMAND.COM from the 'login' prompt leaves 616,000
  645.  bytes free.  By comparison, using COMMAND.COM as the primary shell leaves
  646.  620,000 bytes free.
  647.  
  648.  With a bit of experimentation (and some assistance from MKS Tech Support),
  649.  I was able to get our LANtastic LAN software functioning under the MKS Korn
  650.  shell and 'init', although I did have to load an 'extra' version of
  651.  COMMAND.COM first, using about 2.2K.  The LAN setup was on a network
  652.  workstation, installing the MKS Toolkit on the network server seemed
  653.  to exacerbate an existing and unsolved problem with QEMM intercepts
  654.  and illegal instruction traps on our Northgate 486/33 system.
  655.  
  656.  The MKS Toolkit comes on five 3 1/2" diskettes, and takes a healthy 2.2MB
  657.  for the program files in /bin, and another 646K in the /etc directory, mostly
  658.  for the online man pages file.  Adding the dictionary files and 'spell'
  659.  takes another 1MB or so.
  660.  
  661.  Installation is fairly straight forward, although it took 20 minutes or
  662.  more.  The INSTALL program made some changes to the AUTOEXEC.BAT file
  663.  (after asking), but placed a SET command at the end of the file, where
  664.  it wasn't reached.  The CONFIGURE program takes care of setting up several
  665.  different configurations, but more advance configurations need to be
  666.  tweaked by hand.  My first attempt to install manually produced a few
  667.  minor problems with some files in the wrong place, a re-install and
  668.  CONFIGURE fixed everything up.
  669.  
  670.  Documentation consists of a User's Guide, a Reference Manual, and a DOS
  671.  Installation Manual.  The User's Guide goes into differences in DOS and
  672.  Unix file names at length, and has an excellent tutorial on the Korn
  673.  shell.  The Reference Manual consists of the same type information
  674.  as in the online man pages, although apparently in a bit more depth, and
  675.  is organized like a traditional Unix manual, including a permuted index.
  676.  The DOS Installation Manual gives several examples for configuring the
  677.  MKS Toolkit, especially the Korn shell, including examples beyond the
  678.  capabilities of the install and configure procedures, such as dealing
  679.  with a LAN.
  680.  
  681.  There is a separate installation disk with the MKS Programming Platform,
  682.  which overrides some of the procedures in the MKS Toolkit installation,
  683.  but both performed adequately, except as noted earlier.
  684.  
  685.  The MKS Toolkit for DOS has a list price of $249, but the street price
  686.  is closer to $229.  MKS Awk and MKS VI previously were also available
  687.  separately, but according to MKS this option is being discontinued.
  688.  
  689.  Mortice Kern Systems, Inc.
  690.  35 King Street North
  691.  Waterloo Ontario N2J 2W9 Canada
  692.  519-884-2251.  (US Orders 800-265-2797.)
  693.  ------------
  694.  
  695.  Shells - part 3  (LRARK)  Rick Mobley
  696.  ---------------
  697.  
  698.  This is the third part of this series. In the last part we covered more of
  699.  the basics and got into some variables. If you missed reading it, I suggest
  700.  you go back and review before continuing to press forward. The basics are
  701.  important and will help you discover the heart of this and any other
  702.  sequence.
  703.  
  704.  Last issue we found several uses of special variables available in the
  705.  shell. This issue lets alter some of our own variables to become powerful
  706.  shell programmers.
  707.  
  708.  To capture the output of any command as an argument to another command,
  709.  place that command line within grave accents (` `). The shell will first
  710.  execute the command enclosed within the grave accents. As an example, we can
  711.  assign results to variables.
  712.  
  713.  today=`date`
  714.  
  715.  This would assign the current date string to the variable today.
  716.  
  717.  Now, if you want to assign keyboard input to variables you would probably
  718.  use the built-in read command.
  719.  
  720.  read first init last
  721.  
  722.  will take input of:
  723.  
  724.  Ricky L. Mobley
  725.  
  726.  and assign first=Ricky; init=L.; last=Mobley
  727.  
  728.  Single (' ') and Double (" ") quote marks have different meanings in the
  729.  shell. For instance:
  730.  
  731.  garbage='echo $? $*; ls * | wc'
  732.  
  733.  does nothing but assign that string to the variable garbage. In order to get
  734.  those commands to execute or to allow command substitution to take place
  735.  would mean using the Double quote as:
  736.  
  737.  command="echo $? $*; ls * |wc"
  738.  
  739.  To hide the special meaning of $, `, and " within double quotes, precede
  740.  these characters with a \ (backslash). Outside of double quote marks,
  741.  preceding a character with \ is equivalent to placing it within single quote
  742.  marks.
  743.  
  744.  Most commands do not know, or care, whether their input or output is
  745.  associated with the keyboard, the display, or a file. This makes it very
  746.  convenient to create scripts or to store results in files for later perusal.
  747.  
  748.  When a command begins running, it usually expects that three files are
  749.  already open: standard input, standard output, and diagnostic or error
  750.  output. A number called a file descriptor is associated with each of these
  751.  files:
  752.  
  753.  0 - Standard input
  754.  1 - Standard output
  755.  2 - Diagnostic output (I like to call this 'Standard Error')
  756.  
  757.  A good use of output redirection might be where you expect some error
  758.  messages to occur and want to capture them, along with standard output, to a
  759.  file for later study. Using a command like:
  760.  
  761.  cmd > file 2>&1
  762.  
  763.  would do just that. Note that the 2>&1 must contain no spaces. This will
  764.  associate 1 with file and associate 2 with 1.
  765.  
  766.  The shell provides several flow control commands that are useful in creating
  767.  shell procedures:
  768.  
  769.  for name [in word . . .]
  770.  do list
  771.  done
  772.  
  773.  For each word, sets name to word and executes the commands in list. I use
  774.  this when I have received a group of files that begin with !/bin/sh that
  775.  need to be executed to extract the programs into individual files. I would
  776.  save them in some order like file1.5, file2.5, file3.5, file4.5 and file5.5
  777.  and execute them with:
  778.  
  779.  for file in *.5
  780.  do
  781.  sh $file
  782.  done
  783.  
  784.  Now I can sit back and watch each part (1 through 5) get passed to sh. It is
  785.  important to edit out any garbage before the !/bin/sh before attempting to
  786.  execute it.
  787.  
  788.  case word in
  789.  pattern [|pattern] . . .) list;;
  790.  [ .
  791.          .
  792.          .
  793.  pattern [|pattern] . . .) list;;
  794.  esac
  795.  
  796.  Executes the commands in the list associated with the first pattern that
  797.  matches word.
  798.  
  799.  A simple help attempt can be added to your scripts using this method:
  800.  
  801.  case $1 in
  802.          -h* )
  803.                  usage;
  804.                  exit 1;
  805.          ;;
  806.  
  807.          -t* )
  808.                  extra_text=$2;
  809.                  shift;
  810.          ;;
  811.  esac
  812.  
  813.  Notice 'esac' is 'case' spelled backwards. This would take my first argument
  814.  to prog and test for -h or -t and act accordingly by displaying a usage
  815.  statement if -h means help.
  816.  
  817.  if list
  818.  then list
  819.  [elif list] . . .
  820.  [else list]
  821.  fi
  822.  
  823.  Executes the list following the if keyword. If it returns a zero exit value,
  824.  execute the list following the first then. Otherwise, execute the list
  825.  following elif (if there is an elif), and if its exit value is zero, execute
  826.  the next then. Failing that, execute the list following the else. If no else
  827.  list or then list is executed, the if command returns a zero exit value.
  828.  
  829.  if [ X$EDITOR = X]; then
  830.          editor=vi
  831.  else
  832.          editor=$EDITOR
  833.  fi
  834.  
  835.  Simple but powerful! Execute a test (if) to see if I have an EDITOR defined.
  836.  If not, assign 'vi' as my editor, otherwise assign EDITOR as my editor and
  837.  end the test (fi).
  838.  
  839.  while list
  840.  do list
  841.  done
  842.  
  843.  Executes the list following the while. If the exit value of the last command
  844.  in the list is zero, executes the list following do. Continue looping
  845.  through the lists until the exit value of the last command in the while list
  846.  is nonzero. In other words, continue the loop, test at the bottom, and exit
  847.  only when the last command is nonzero.
  848.  
  849.  while :
  850.  do
  851.  ls -l
  852.  sleep 5
  853.  done
  854.  
  855.  This means, while forever do ls -l, sleep 5 seconds and continue. You have
  856.  to hit the delete key on this one to force an exit. Its useful to watch a
  857.  directory while someone spools you a file. When the size stops growing it
  858.  has been received.
  859.  
  860.  until list
  861.  do list
  862.  done
  863.  
  864.  Executes the list following the until. If the exit value of the last command
  865.  in the list is nonzero, executes the list following do. Continues looping
  866.  through the lists until the exit value of the last command in the until list
  867.  is zero. If no commands in the do list are executed, the until command
  868.  returns a zero exit value.
  869.  
  870.  Sound familiar, its a !while.
  871.  
  872.  Note:
  873.  
  874.  (list)  Executes the commands in list in a subshell.
  875.  
  876.  {list;} Executes the commands in list in the current shell process.
  877.          (does not spawn a subshell).
  878.  
  879.  
  880.  In the next installment I will continue with built in commands and see what
  881.  happens when we run the Shell.
  882.  
  883.  Ricky Mobley [lrark]
  884.  Little Rock, AR
  885.  ------------
  886.  
  887.  FAST and NASTY, DOWN  and  DIRTY:  quick  fix scripts that do something
  888.  ================================
  889.  
  890.  Article 5298 of comp.unix.shell:
  891.  Path: glsrk!lrark!ddi1!uunet!uunet!van-bc!twg!bill
  892.  From: bill@twg.bc.ca (Bill Irwin)
  893.  Newsgroups: comp.unix.shell
  894.  Subject: Re: Automatic Shell script for watching disk space
  895.  Message-ID: <2542@twg.bc.ca>
  896.  Date: 14 Jul 92 22:00:51 GMT
  897.  References: <HARI.92Jul3231707@robios6.me.wisc.edu>
  898.  Reply-To: bill@twg.bc.ca (Bill Irwin)
  899.  Organization: The Westrheim Group, Vancouver, B.C., Canada
  900.  
  901.  hari@robios.me.wisc.edu (Kambainathan Hari) writes:
  902.  
  903.  : To begin with I have hardly written any shell scripts & I apologize if
  904.  : this seems simple. Here's the problem:
  905.  
  906.  : I am looking for script to check if the /usr partition has exceeded a
  907.  : certain % of disk space. If so, to mail me a warning message.
  908.  
  909.  Since none of the replies so far have specifically mentioned SCO
  910.  XENIX, I might as well throw out what we use here.  I just
  911.  noticed that it could probably handle the mail versus display
  912.  option more elegantly.  It is called "disklow" on our system, so
  913.  to mail the output use "disklow username".  To display on screen,
  914.  just "disklow".
  915.  
  916.  ----------------- snip  8<  8<  8<  snip ------------
  917.  :
  918.  Used=95         # Percent of file system used for warning.
  919.  Blocks=5000     # Minimum free blocks
  920.  Warning=no
  921.  [ $# -gt 0 ] && MailTo=$1 # Alternate to mail to.
  922.  for Sizes in `df -v | grep -v Filesystem|awk '{print $6}'`
  923.  do
  924.          if [ $Sizes -gt $Used ]
  925.          then Print=yes
  926.          fi
  927.  done
  928.  for Sizes in `df -v | grep -v Filesystem|awk '{print $5}'`
  929.  do
  930.          if [ $Sizes -lt $Blocks ]
  931.          then Print=yes
  932.          fi
  933.  done
  934.  if [ ${Print=no} = yes ]
  935.  then
  936.  case $MailTo in
  937.          [A-z0-9]*)
  938.          TempFile=/tmp/dl.$$
  939.          echo "File System          % Used" >$TempFile
  940.          echo "-----------          ------     ---------Free Space--------\n"\         >>$TempFile
  941.          df -v | grep -v Filesystem | \
  942.          awk '{
  943.          if( $6 > '$Used' || '$Blocks' > $5 )
  944.             printf( "%-10s\t\t%s\t%6d blocks   %3d.%1d Mbytes\n", \
  945.             $2, $6, $5, $5 * 512 / 1000000, $5 * 512 % 1000000 / 100000 )}'\
  946.             >> $TempFile
  947.          mail -s "*** WARNING *** Disk Low" $MailTo <$TempFile
  948.          rm $TempFile
  949.          ;;
  950.          *)
  951.          echo "File System          % Used"
  952.          echo "-----------          ------     ---------Free  Space--------\n"
  953.          df -v | grep -v Filesystem | \
  954.          awk '{
  955.          if( $6 > '$Used' || '$Blocks' > $5 )
  956.             printf( "%-10s\t\t%s\t%6d blocks   %3d.%1d Mbytes\n", \
  957.             $2, $6, $5, $5 * 512 / 1000000, $5 * 512 % 1000000 / 100000 )}'
  958.          ;;
  959.  esac
  960.  else
  961.          echo "No file systems low on space."
  962.  fi
  963.  ----------------- snip  8<  8<  8<  snip ------------
  964.  --
  965.  Bill Irwin    -       The Westrheim Group     -    Vancouver, BC, Canada
  966.  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  967.  uunet!twg!bill            (604) 431-9600 (voice) |     Your Computer
  968.  bill@twg.bc.ca            (604) 430-4329 (fax)   |    Systems Partner
  969.  
  970.  
  971.    ---------------
  972.   REMINDER - This newsletter is being sent to you 'by request'. If you do
  973.  not wish to keep receiving it, e-mail a stop notice to GARS. On the other
  974.  hand, we would very much appreciate it if you would pass the word that we
  975.  do distribute this item near the tenth (10th) of the month of issue to any-
  976.  one on GEnie who requests it.
  977.    P L E A S E  also remember contributions are most welcome. Please e-mail
  978.  items and/or suggestions to GARS.
  979.  
  980.   (EOF)
  981.  
  982.  Trademark and Copyright notices:
  983.  Unix is a Trademark of UNIX System Laboratories, Inc.; GEnie, LiveWire, and
  984.  RoundTable are Trademarks of General Electric Information Services  Company;
  985.  Xenix and ms-dos are Trademarks of  Microsoft  Corporation; NeXT and NeXTstep
  986.  are Trademarks of NeXT Computer Systems, Inc., Coherent is a Trademark of
  987.  Mark Williams Company, Sun is a Trademark of Sun Microsystems, Inc., MKS is
  988.  a Trademark of Mortice Kern Systems, Inc.
  989.  
  990.  The contents of this newsletter are copyright(c) 1992 and may be copied whole
  991.  or in part only if original  credit is included. The GEnie UNIX RoundTable is
  992.  not affiliated with AT&T or UNIX System Laboratories, Inc.
  993.  
  994.  
  995.